;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.0.0 #6037 (Jul 16 2012) (Mac OS X x86_64)
; This file was generated Mon Sep 17 23:12:35 2012
;--------------------------------------------------------
; PIC16 port for the Microchip 16-bit core micros
;--------------------------------------------------------
	list	p=18f2550
	__config 0x300000, 0xc4
	__config 0x300001, 0x3c
	__config 0x300002, 0xf7
	__config 0x300003, 0xfe
	__config 0x300005, 0xf8
	__config 0x300006, 0x9b
	__config 0x300008, 0xff
	__config 0x300009, 0xff
	__config 0x30000a, 0xff
	__config 0x30000b, 0xff
	__config 0x30000c, 0xff
	__config 0x30000d, 0xff

	radix dec

;--------------------------------------------------------
; public variables in this module
;--------------------------------------------------------
	global _direction
	global _sleep_ms
	global _fade_in
	global _fade_out
	global _forward_dias
	global _backward_dias
	global _sync_dias
	global _my_usart_open
	global _wait_for_command
	global _led_debug
	global _fifo_in_use
	global _fifo_put
	global _fifo_get
	global _fifo_snoop
	global _fifo_get_optimized
	global _read_EEPROM
	global _write_EEPROM
	global _dimmer_count
	global _dimmer_level
	global _max_dimmer_level
	global _dimmer_time
	global _ad0
	global _ad1
	global _timer_2
	global _timer_1_soft_postscaler
	global _dimmer_direction
	global _dias_num
	global _dias_position
	global _fifo_head
	global _fifo_tail
	global _fifo_buffer
	global _command
	global _id
	global _eeprom_id
	global _main

;--------------------------------------------------------
; extern variables in this module
;--------------------------------------------------------
	extern __gptrput1
	extern __moduchar
	extern _SPPDATAbits
	extern _SPPCFGbits
	extern _SPPEPSbits
	extern _SPPCONbits
	extern _UFRMLbits
	extern _UFRMHbits
	extern _UIRbits
	extern _UIEbits
	extern _UEIRbits
	extern _UEIEbits
	extern _USTATbits
	extern _UCONbits
	extern _UADDRbits
	extern _UCFGbits
	extern _UEP0bits
	extern _UEP1bits
	extern _UEP2bits
	extern _UEP3bits
	extern _UEP4bits
	extern _UEP5bits
	extern _UEP6bits
	extern _UEP7bits
	extern _UEP8bits
	extern _UEP9bits
	extern _UEP10bits
	extern _UEP11bits
	extern _UEP12bits
	extern _UEP13bits
	extern _UEP14bits
	extern _UEP15bits
	extern _PORTAbits
	extern _PORTBbits
	extern _PORTCbits
	extern _PORTDbits
	extern _PORTEbits
	extern _LATAbits
	extern _LATBbits
	extern _LATCbits
	extern _LATDbits
	extern _LATEbits
	extern _TRISAbits
	extern _TRISBbits
	extern _TRISCbits
	extern _TRISDbits
	extern _TRISEbits
	extern _OSCTUNEbits
	extern _PIE1bits
	extern _PIR1bits
	extern _IPR1bits
	extern _PIE2bits
	extern _PIR2bits
	extern _IPR2bits
	extern _EECON1bits
	extern _RCSTAbits
	extern _TXSTAbits
	extern _T3CONbits
	extern _CMCONbits
	extern _CVRCONbits
	extern _ECCP1ASbits
	extern _ECCP1DELbits
	extern _BAUDCONbits
	extern _CCP2CONbits
	extern _CCP1CONbits
	extern _ADCON2bits
	extern _ADCON1bits
	extern _ADCON0bits
	extern _SSPCON2bits
	extern _SSPCON1bits
	extern _SSPSTATbits
	extern _T2CONbits
	extern _T1CONbits
	extern _RCONbits
	extern _WDTCONbits
	extern _HLVDCONbits
	extern _OSCCONbits
	extern _T0CONbits
	extern _STATUSbits
	extern _FSR2Hbits
	extern _BSRbits
	extern _FSR1Hbits
	extern _FSR0Hbits
	extern _INTCON3bits
	extern _INTCON2bits
	extern _INTCONbits
	extern _TBLPTRUbits
	extern _PCLATHbits
	extern _PCLATUbits
	extern _STKPTRbits
	extern _TOSUbits
	extern _stdin
	extern _stdout
	extern _SPPDATA
	extern _SPPCFG
	extern _SPPEPS
	extern _SPPCON
	extern _UFRML
	extern _UFRMH
	extern _UIR
	extern _UIE
	extern _UEIR
	extern _UEIE
	extern _USTAT
	extern _UCON
	extern _UADDR
	extern _UCFG
	extern _UEP0
	extern _UEP1
	extern _UEP2
	extern _UEP3
	extern _UEP4
	extern _UEP5
	extern _UEP6
	extern _UEP7
	extern _UEP8
	extern _UEP9
	extern _UEP10
	extern _UEP11
	extern _UEP12
	extern _UEP13
	extern _UEP14
	extern _UEP15
	extern _PORTA
	extern _PORTB
	extern _PORTC
	extern _PORTD
	extern _PORTE
	extern _LATA
	extern _LATB
	extern _LATC
	extern _LATD
	extern _LATE
	extern _TRISA
	extern _TRISB
	extern _TRISC
	extern _TRISD
	extern _TRISE
	extern _OSCTUNE
	extern _PIE1
	extern _PIR1
	extern _IPR1
	extern _PIE2
	extern _PIR2
	extern _IPR2
	extern _EECON1
	extern _EECON2
	extern _EEDATA
	extern _EEADR
	extern _RCSTA
	extern _TXSTA
	extern _TXREG
	extern _RCREG
	extern _SPBRG
	extern _SPBRGH
	extern _T3CON
	extern _TMR3L
	extern _TMR3H
	extern _CMCON
	extern _CVRCON
	extern _ECCP1AS
	extern _ECCP1DEL
	extern _BAUDCON
	extern _CCP2CON
	extern _CCPR2L
	extern _CCPR2H
	extern _CCP1CON
	extern _CCPR1L
	extern _CCPR1H
	extern _ADCON2
	extern _ADCON1
	extern _ADCON0
	extern _ADRESL
	extern _ADRESH
	extern _SSPCON2
	extern _SSPCON1
	extern _SSPSTAT
	extern _SSPADD
	extern _SSPBUF
	extern _T2CON
	extern _PR2
	extern _TMR2
	extern _T1CON
	extern _TMR1L
	extern _TMR1H
	extern _RCON
	extern _WDTCON
	extern _HLVDCON
	extern _OSCCON
	extern _T0CON
	extern _TMR0L
	extern _TMR0H
	extern _STATUS
	extern _FSR2L
	extern _FSR2H
	extern _PLUSW2
	extern _PREINC2
	extern _POSTDEC2
	extern _POSTINC2
	extern _INDF2
	extern _BSR
	extern _FSR1L
	extern _FSR1H
	extern _PLUSW1
	extern _PREINC1
	extern _POSTDEC1
	extern _POSTINC1
	extern _INDF1
	extern _WREG
	extern _FSR0L
	extern _FSR0H
	extern _PLUSW0
	extern _PREINC0
	extern _POSTDEC0
	extern _POSTINC0
	extern _INDF0
	extern _INTCON3
	extern _INTCON2
	extern _INTCON
	extern _PRODL
	extern _PRODH
	extern _TABLAT
	extern _TBLPTRL
	extern _TBLPTRH
	extern _TBLPTRU
	extern _PCL
	extern _PCLATH
	extern _PCLATU
	extern _STKPTR
	extern _TOSL
	extern _TOSH
	extern _TOSU
	extern _adc_open
	extern _adc_conv
	extern _adc_busy
	extern _adc_read
	extern _adc_setchannel
	extern _usart_drdy
	extern _usart_getc
	extern _usart_putc
	extern __mullong
;--------------------------------------------------------
;	Equates to used internal registers
;--------------------------------------------------------
STATUS	equ	0xfd8
PCLATH	equ	0xffa
PCLATU	equ	0xffb
WREG	equ	0xfe8
BSR	equ	0xfe0
FSR0L	equ	0xfe9
FSR0H	equ	0xfea
FSR1L	equ	0xfe1
FSR2L	equ	0xfd9
INDF0	equ	0xfef
POSTDEC1	equ	0xfe5
PREINC1	equ	0xfe4
PLUSW2	equ	0xfdb
PRODL	equ	0xff3
PRODH	equ	0xff4


; Internal registers
.registers	udata_ovr	0x0000
r0x00	res	1
r0x01	res	1
r0x02	res	1
r0x03	res	1
r0x04	res	1
r0x05	res	1
r0x06	res	1
r0x07	res	1
r0x08	res	1
r0x09	res	1
r0x0a	res	1
r0x0b	res	1
r0x0c	res	1
r0x0d	res	1
r0x0e	res	1
r0x0f	res	1

udata_kodak_timer_0	udata
_direction	res	1

udata_kodak_timer_1	udata
_timer_2	res	4

udata_kodak_timer_2	udata
_timer_1_soft_postscaler	res	2

udata_kodak_timer_3	udata
_dimmer_level	res	1

udata_kodak_timer_4	udata
_dimmer_time	res	2

udata_kodak_timer_5	udata
_max_dimmer_level	res	1

udata_kodak_timer_6	udata
_dias_num	res	1

udata_kodak_timer_7	udata
_dias_position	res	1

udata_kodak_timer_8	udata
_fifo_head	res	2

udata_kodak_timer_9	udata
_fifo_tail	res	2

udata_kodak_timer_10	udata
_eeprom_id	res	1

udata_kodak_timer_11	udata
_command	res	1

udata_kodak_timer_12	udata
_dimmer_direction	res	1

udata_kodak_timer_13	udata
_dimmer_count	res	1

udata_kodak_timer_14	udata
_ad0	res	1

udata_kodak_timer_15	udata
_ad1	res	1

udata_kodak_timer_16	udata
_id	res	1

udata_kodak_timer_17	udata
_fifo_buffer	res	256

udata_kodak_timer_18	udata
_fifo_get_optimized_a_1_1	res	1

udata_kodak_timer_19	udata
_fifo_get_optimized_b_1_1	res	1

;--------------------------------------------------------
; interrupt vector 
;--------------------------------------------------------

;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
; ; Starting pCode block for absolute section
; ;-----------------------------------------
S_kodak_timer_ivec_0x1_phase_control	code	0X000008
ivec_0x1_phase_control:
	GOTO	_phase_control

; ; Starting pCode block for absolute section
; ;-----------------------------------------
S_kodak_timer_ivec_0x2_timer_control	code	0X000018
ivec_0x2_timer_control:
	GOTO	_timer_control

; I code from now on!
; ; Starting pCode block
S_kodak_timer__main	code
_main:
;	.line	39; kodak_timer.c	OSCCONbits.SCS = 0x0;			// System Clock Select bits = External oscillator
	MOVF	_OSCCONbits, W
	ANDLW	0xfc
	MOVWF	_OSCCONbits
;	.line	40; kodak_timer.c	OSCCONbits.IRCF = 0x7;		// Internal Oscillator Frequency Select bits 8 MHz (INTOSC drives clock directly)
	MOVF	_OSCCONbits, W
	ANDLW	0x8f
	IORLW	0x70
	MOVWF	_OSCCONbits
;	.line	42; kodak_timer.c	TRIS_ZERO_CROSS_DETECTOR_PIN = 1;
	BSF	_TRISBbits, 0
;	.line	43; kodak_timer.c	TRIS_BACKWARD_PIN = 0;
	BCF	_TRISBbits, 1
;	.line	44; kodak_timer.c	TRIS_FORWARD_PIN = 0;
	BCF	_TRISBbits, 2
;	.line	45; kodak_timer.c	TRIS_LAMP_PIN  = 0;
	BCF	_TRISBbits, 3
;	.line	46; kodak_timer.c	TRIS_DIAS_DETECTOR_PIN = 1;
	BSF	_TRISBbits, 4
;	.line	47; kodak_timer.c	TRIS_LED = 0;
	BCF	_TRISBbits, 5
;	.line	49; kodak_timer.c	TRIS_AD_0 = 1;
	BSF	_TRISAbits, 0
;	.line	50; kodak_timer.c	TRIS_AD_1 = 1;
	BSF	_TRISAbits, 1
;	.line	52; kodak_timer.c	TRIS_TX_PIN = 0;
	BCF	_TRISCbits, 6
;	.line	53; kodak_timer.c	TRIS_RX_PIN = 1;
	BSF	_TRISCbits, 7
;	.line	55; kodak_timer.c	BACKWARD_PIN = 0;
	BCF	_PORTBbits, 1
;	.line	56; kodak_timer.c	FORWARD_PIN = 0;
	BCF	_PORTBbits, 2
;	.line	57; kodak_timer.c	LAMP_PIN = 0;
	BCF	_PORTBbits, 3
;	.line	58; kodak_timer.c	LED_PIN = 0;
	BCF	_PORTBbits, 5
	BANKSEL	_timer_2
;	.line	60; kodak_timer.c	timer_2 = 0;
	CLRF	_timer_2, B
	BANKSEL	(_timer_2 + 1)
	CLRF	(_timer_2 + 1), B
	BANKSEL	(_timer_2 + 2)
	CLRF	(_timer_2 + 2), B
	BANKSEL	(_timer_2 + 3)
	CLRF	(_timer_2 + 3), B
	BANKSEL	_timer_1_soft_postscaler
;	.line	61; kodak_timer.c	timer_1_soft_postscaler = 0;
	CLRF	_timer_1_soft_postscaler, B
	BANKSEL	(_timer_1_soft_postscaler + 1)
	CLRF	(_timer_1_soft_postscaler + 1), B
	BANKSEL	_dimmer_level
;	.line	62; kodak_timer.c	dimmer_level = 0;
	CLRF	_dimmer_level, B
	BANKSEL	_dimmer_time
;	.line	63; kodak_timer.c	dimmer_time = 0;
	CLRF	_dimmer_time, B
	BANKSEL	(_dimmer_time + 1)
	CLRF	(_dimmer_time + 1), B
;	.line	64; kodak_timer.c	max_dimmer_level = MAX_DIMMER_LEVEL;
	MOVLW	0xc8
	BANKSEL	_max_dimmer_level
	MOVWF	_max_dimmer_level, B
	BANKSEL	_dias_num
;	.line	66; kodak_timer.c	dias_num = 0;
	CLRF	_dias_num, B
	BANKSEL	_dias_position
;	.line	67; kodak_timer.c	dias_position = 0;
	CLRF	_dias_position, B
	BANKSEL	_fifo_head
;	.line	69; kodak_timer.c	fifo_head = 0;
	CLRF	_fifo_head, B
	BANKSEL	(_fifo_head + 1)
	CLRF	(_fifo_head + 1), B
	BANKSEL	_fifo_tail
;	.line	70; kodak_timer.c	fifo_tail = 0;
	CLRF	_fifo_tail, B
	BANKSEL	(_fifo_tail + 1)
	CLRF	(_fifo_tail + 1), B
;	.line	74; kodak_timer.c	eeprom_id = 114;
	MOVLW	0x72
	BANKSEL	_eeprom_id
	MOVWF	_eeprom_id, B
;	.line	80; kodak_timer.c	adc_open(2, ADC_FOSC_64, ADC_CFG_2A, ADC_FRM_RJUST | ADC_INT_OFF);
	MOVLW	0x80
	MOVWF	POSTDEC1
	MOVLW	0x0d
	MOVWF	POSTDEC1
	MOVLW	0x06
	MOVWF	POSTDEC1
	MOVLW	0x02
	MOVWF	POSTDEC1
	CALL	_adc_open
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	83; kodak_timer.c	RCONbits.IPEN = 1;
	BSF	_RCONbits, 7
;	.line	86; kodak_timer.c	IPR1bits.RCIP = 0;
	BCF	_IPR1bits, 5
;	.line	87; kodak_timer.c	IPR1bits.TXIP = 0;
	BCF	_IPR1bits, 4
;	.line	90; kodak_timer.c	T0CONbits.TMR0ON = 0;
	BCF	_T0CONbits, 7
;	.line	91; kodak_timer.c	T0CONbits.T08BIT = 0;	// use timer0 16-bit counter
	BCF	_T0CONbits, 6
;	.line	92; kodak_timer.c	T0CONbits.T0CS = 0;		// internal clock source
	BCF	_T0CONbits, 5
;	.line	93; kodak_timer.c	T0CONbits.PSA = 1;		// disable timer0 prescaler
	BSF	_T0CONbits, 3
;	.line	94; kodak_timer.c	INTCON2bits.TMR0IP = 1;	// high priority
	BSF	_INTCON2bits, 2
;	.line	97; kodak_timer.c	T1CONbits.TMR1ON = 0;
	BCF	_T1CONbits, 0
;	.line	98; kodak_timer.c	T1CONbits.RD16 = 1;
	BSF	_T1CONbits, 7
;	.line	99; kodak_timer.c	T1CONbits.TMR1CS = 0;	// internal clock source
	BCF	_T1CONbits, 1
;	.line	100; kodak_timer.c	T1CONbits.T1OSCEN = 0;	// dont put t1 on pin
	BCF	_T1CONbits, 3
;	.line	101; kodak_timer.c	T1CONbits.T1CKPS0 = 1;
	BSF	_T1CONbits, 4
;	.line	102; kodak_timer.c	T1CONbits.T1CKPS1 = 1;
	BSF	_T1CONbits, 5
;	.line	103; kodak_timer.c	IPR1bits.TMR1IP = 0;		// low priority
	BCF	_IPR1bits, 0
;	.line	106; kodak_timer.c	T2CONbits.T2CKPS0 = 1;
	BSF	_T2CONbits, 0
;	.line	107; kodak_timer.c	T2CONbits.T2CKPS1 = 0;
	BCF	_T2CONbits, 1
;	.line	108; kodak_timer.c	T2CONbits.TOUTPS0 = 1;
	BSF	_T2CONbits, 3
;	.line	109; kodak_timer.c	T2CONbits.TOUTPS1 = 0;
	BCF	_T2CONbits, 4
;	.line	110; kodak_timer.c	T2CONbits.TOUTPS2 = 0;
	BCF	_T2CONbits, 5
;	.line	111; kodak_timer.c	T2CONbits.TOUTPS3 = 1;
	BSF	_T2CONbits, 6
;	.line	112; kodak_timer.c	IPR1bits.TMR2IP = 0;		// low priority
	BCF	_IPR1bits, 1
;	.line	113; kodak_timer.c	PIR1bits.TMR2IF = 1;
	BSF	_PIR1bits, 1
;	.line	114; kodak_timer.c	T2CONbits.TMR2ON = 1;
	BSF	_T2CONbits, 2
;	.line	115; kodak_timer.c	PIE1bits.TMR2IE = 1;
	BSF	_PIE1bits, 1
;	.line	118; kodak_timer.c	T3CONbits.RD16 = 1;
	BSF	_T3CONbits, 7
;	.line	119; kodak_timer.c	T3CONbits.TMR3CS = 0;	// internal clock source
	BCF	_T3CONbits, 1
;	.line	120; kodak_timer.c	T3CONbits.T3CKPS0 = 1;
	BSF	_T3CONbits, 4
;	.line	121; kodak_timer.c	T3CONbits.T3CKPS0 = 1;
	BSF	_T3CONbits, 4
;	.line	122; kodak_timer.c	IPR2bits.TMR3IP = 0;		// low priority
	BCF	_IPR2bits, 1
;	.line	123; kodak_timer.c	T3CONbits.TMR3ON = 1;
	BSF	_T3CONbits, 0
;	.line	124; kodak_timer.c	PIE2bits.TMR3IE = 1;
	BSF	_PIE2bits, 1
;	.line	125; kodak_timer.c	PIR2bits.TMR3IF = 1;
	BSF	_PIR2bits, 1
;	.line	127; kodak_timer.c	INTCONbits.INT0IE = 0;	// zero-cross interrupt - enabled when we dimm in
	BCF	_INTCONbits, 4
;	.line	129; kodak_timer.c	INTCONbits.PEIE = 1;
	BSF	_INTCONbits, 6
;	.line	130; kodak_timer.c	INTCONbits.GIE = 1;	/* Enable Global interrupts   */	
	BSF	_INTCONbits, 7
;	.line	143; kodak_timer.c	my_usart_open();
	CALL	_my_usart_open
;	.line	152; kodak_timer.c	sync_dias(1);
	MOVLW	0x01
	MOVWF	POSTDEC1
	CALL	_sync_dias
	INCF	FSR1L, F
_00112_DS_:
;	.line	155; kodak_timer.c	wait_for_command();
	CALL	_wait_for_command
;	.line	156; kodak_timer.c	switch (command) {
	MOVFF	_command, r0x00
	MOVF	r0x00, W
	XORLW	0x01
	BZ	_00108_DS_
	MOVF	r0x00, W
	XORLW	0x02
	BZ	_00107_DS_
	MOVF	r0x00, W
	XORLW	0x03
	BZ	_00105_DS_
	MOVF	r0x00, W
	XORLW	0x06
	BZ	_00106_DS_
	MOVF	r0x00, W
	XORLW	0x07
	BZ	_00109_DS_
	BRA	_00112_DS_
_00105_DS_:
;	.line	158; kodak_timer.c	sync_dias(1);
	MOVLW	0x01
	MOVWF	POSTDEC1
	CALL	_sync_dias
	INCF	FSR1L, F
;	.line	159; kodak_timer.c	break;
	BRA	_00112_DS_
_00106_DS_:
;	.line	161; kodak_timer.c	forward_dias();
	CALL	_forward_dias
;	.line	162; kodak_timer.c	break;
	BRA	_00112_DS_
_00107_DS_:
;	.line	164; kodak_timer.c	backward_dias();
	CALL	_backward_dias
;	.line	165; kodak_timer.c	break;
	BRA	_00112_DS_
_00108_DS_:
;	.line	167; kodak_timer.c	fade_in();
	CALL	_fade_in
;	.line	168; kodak_timer.c	break;
	BRA	_00112_DS_
_00109_DS_:
;	.line	170; kodak_timer.c	fade_out();
	CALL	_fade_out
;	.line	172; kodak_timer.c	}
	BRA	_00112_DS_
	RETURN	

; ; Starting pCode block
S_kodak_timer__write_EEPROM	code
_write_EEPROM:
;	.line	586; kodak_timer.c	void write_EEPROM(unsigned char address, unsigned char d) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
	MOVLW	0x03
	MOVFF	PLUSW2, r0x01
;	.line	588; kodak_timer.c	save_int = INTCON;					//save interrupt status
	MOVFF	_INTCON, r0x02
;	.line	589; kodak_timer.c	EECON1 = 0;									//ensure CFGS=0 and EEPGD=0
	CLRF	_EECON1
;	.line	590; kodak_timer.c	EECON1bits.WREN = 1;				//enable write to EEPROM
	BSF	_EECON1bits, 2
;	.line	591; kodak_timer.c	EEADR = address;						//setup Address
	MOVFF	r0x00, _EEADR
;	.line	592; kodak_timer.c	EEDATA = d;									//and data
	MOVFF	r0x01, _EEDATA
;	.line	593; kodak_timer.c	INTCONbits.GIE=0;						//No interrupts
	BCF	_INTCONbits, 7
;	.line	594; kodak_timer.c	EECON2 = 0x55;							//required sequence #1
	MOVLW	0x55
	MOVWF	_EECON2
;	.line	595; kodak_timer.c	EECON2 = 0xaa;							//#2
	MOVLW	0xaa
	MOVWF	_EECON2
;	.line	596; kodak_timer.c	EECON1bits.WR = 1;					//#3 = actual write
	BSF	_EECON1bits, 1
;	.line	597; kodak_timer.c	INTCON = save_int;					//restore interrupts
	MOVFF	r0x02, _INTCON
_00470_DS_:
;	.line	598; kodak_timer.c	while(!PIR2bits.EEIF) {
	BTFSS	_PIR2bits, 4
	BRA	_00470_DS_
;	.line	601; kodak_timer.c	EECON1bits.WREN = 0;				//disable write to EEPROM
	BCF	_EECON1bits, 2
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__read_EEPROM	code
_read_EEPROM:
;	.line	579; kodak_timer.c	unsigned char read_EEPROM(unsigned char address) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
;	.line	580; kodak_timer.c	EECON1 = 0;									//ensure CFGS = 0 and EEPGD = 0 
	CLRF	_EECON1
;	.line	581; kodak_timer.c	EEADR = address;
	MOVFF	r0x00, _EEADR
;	.line	582; kodak_timer.c	EECON1bits.RD = 1;
	BSF	_EECON1bits, 0
;	.line	583; kodak_timer.c	return(EEDATA);
	MOVF	_EEDATA, W
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__fifo_get_optimized	code
_fifo_get_optimized:
;	.line	524; kodak_timer.c	unsigned char fifo_get_optimized(command_t *c) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVFF	r0x05, POSTDEC1
	MOVFF	r0x06, POSTDEC1
	MOVFF	r0x07, POSTDEC1
	MOVFF	r0x08, POSTDEC1
	MOVFF	r0x09, POSTDEC1
	MOVFF	r0x0a, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
	MOVLW	0x03
	MOVFF	PLUSW2, r0x01
	MOVLW	0x04
	MOVFF	PLUSW2, r0x02
;	.line	532; kodak_timer.c	in_use = fifo_in_use();
	CALL	_fifo_in_use
	MOVWF	r0x03
	BANKSEL	_dias_num
;	.line	533; kodak_timer.c	if (in_use >= dias_num) {
	MOVF	_dias_num, W, B
	SUBWF	r0x03, W
	BTFSS	STATUS, 0
	BRA	_00407_DS_
;	.line	535; kodak_timer.c	for (i = 0; i < in_use; i++) {
	CLRF	r0x04
	CLRF	r0x05
_00413_DS_:
	MOVF	r0x03, W
	SUBWF	r0x05, W
	BC	_00416_DS_
;	.line	536; kodak_timer.c	fifo_snoop(&a, i);
	MOVLW	HIGH(_fifo_get_optimized_a_1_1)
	MOVWF	r0x07
	MOVLW	LOW(_fifo_get_optimized_a_1_1)
	MOVWF	r0x06
	MOVLW	0x80
	MOVWF	r0x08
	MOVF	r0x05, W
	MOVWF	POSTDEC1
	MOVF	r0x08, W
	MOVWF	POSTDEC1
	MOVF	r0x07, W
	MOVWF	POSTDEC1
	MOVF	r0x06, W
	MOVWF	POSTDEC1
	CALL	_fifo_snoop
	MOVLW	0x04
	ADDWF	FSR1L, F
	BANKSEL	_fifo_get_optimized_a_1_1
;	.line	537; kodak_timer.c	if (a == CMD_FORWARD) {
	MOVF	_fifo_get_optimized_a_1_1, W, B
	XORLW	0x06
	BNZ	_00415_DS_
;	.line	538; kodak_timer.c	cmd_next_num++;
	INCF	r0x04, F
_00415_DS_:
;	.line	535; kodak_timer.c	for (i = 0; i < in_use; i++) {
	INCF	r0x05, F
	BRA	_00413_DS_
_00416_DS_:
;	.line	541; kodak_timer.c	cmd_next_nums_to_remove = cmd_next_num - (cmd_next_num % dias_num);
	MOVFF	_dias_num, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	CALL	__moduchar
	MOVWF	r0x03
	MOVF	PREINC1, W
	MOVF	PREINC1, W
	MOVF	r0x03, W
	SUBWF	r0x04, W
	MOVWF	r0x03
_00394_DS_:
;	.line	544; kodak_timer.c	while (cmd_next_nums_to_remove > 0) {
	MOVF	r0x03, W
	BTFSC	STATUS, 2
	BRA	_00407_DS_
;	.line	545; kodak_timer.c	for (i = fifo_in_use(); i > 1; i--) {
	CALL	_fifo_in_use
	MOVWF	r0x04
	MOVFF	r0x03, r0x05
_00417_DS_:
	MOVLW	0x02
	SUBWF	r0x04, W
	BNC	_00394_DS_
;	.line	546; kodak_timer.c	fifo_snoop(&a, (i - 1));
	MOVLW	HIGH(_fifo_get_optimized_a_1_1)
	MOVWF	r0x07
	MOVLW	LOW(_fifo_get_optimized_a_1_1)
	MOVWF	r0x06
	MOVLW	0x80
	MOVWF	r0x08
	DECF	r0x04, W
	MOVWF	r0x09
	MOVF	r0x09, W
	MOVWF	POSTDEC1
	MOVF	r0x08, W
	MOVWF	POSTDEC1
	MOVF	r0x07, W
	MOVWF	POSTDEC1
	MOVF	r0x06, W
	MOVWF	POSTDEC1
	CALL	_fifo_snoop
	MOVLW	0x04
	ADDWF	FSR1L, F
	BANKSEL	_fifo_get_optimized_a_1_1
;	.line	547; kodak_timer.c	if ((a == CMD_FORWARD) && (cmd_next_nums_to_remove > 0)) {
	MOVF	_fifo_get_optimized_a_1_1, W, B
	XORLW	0x06
	BZ	_00450_DS_
	BRA	_00419_DS_
_00450_DS_:
	MOVF	r0x05, W
	BTFSC	STATUS, 2
	BRA	_00419_DS_
;	.line	550; kodak_timer.c	while (j > 1) {
	MOVFF	r0x04, r0x06
_00388_DS_:
	MOVLW	0x02
	SUBWF	r0x06, W
	BNC	_00390_DS_
;	.line	551; kodak_timer.c	fifo_buffer[fifo_tail + j - 1] = fifo_buffer[fifo_tail + (j - 1 - 1)];
	MOVFF	r0x06, r0x07
	CLRF	r0x08
	MOVF	r0x07, W
	BANKSEL	_fifo_tail
	ADDWF	_fifo_tail, W, B
	MOVWF	r0x09
	MOVF	r0x08, W
	BANKSEL	(_fifo_tail + 1)
	ADDWFC	(_fifo_tail + 1), W, B
	MOVWF	r0x0a
	MOVLW	0xff
	ADDWF	r0x09, F
	BTFSS	STATUS, 0
	DECF	r0x0a, F
	MOVLW	LOW(_fifo_buffer)
	ADDWF	r0x09, F
	MOVLW	HIGH(_fifo_buffer)
	ADDWFC	r0x0a, F
	MOVLW	0xfe
	ADDWF	r0x07, F
	BTFSS	STATUS, 0
	DECF	r0x08, F
	BANKSEL	_fifo_tail
	MOVF	_fifo_tail, W, B
	ADDWF	r0x07, F
	BANKSEL	(_fifo_tail + 1)
	MOVF	(_fifo_tail + 1), W, B
	ADDWFC	r0x08, F
	MOVLW	LOW(_fifo_buffer)
	ADDWF	r0x07, F
	MOVLW	HIGH(_fifo_buffer)
	ADDWFC	r0x08, F
	MOVFF	r0x07, FSR0L
	MOVFF	r0x08, FSR0H
	MOVFF	INDF0, r0x07
	MOVFF	r0x09, FSR0L
	MOVFF	r0x0a, FSR0H
	MOVFF	r0x07, INDF0
;	.line	552; kodak_timer.c	j--;
	DECF	r0x06, F
	BRA	_00388_DS_
_00390_DS_:
	BANKSEL	_fifo_tail
;	.line	554; kodak_timer.c	fifo_tail++;
	INCF	_fifo_tail, F, B
	BNC	_10470_DS_
	BANKSEL	(_fifo_tail + 1)
	INCF	(_fifo_tail + 1), F, B
_10470_DS_:
;	.line	555; kodak_timer.c	cmd_next_nums_to_remove--;
	DECF	r0x05, F
	MOVFF	r0x05, r0x03
_00419_DS_:
;	.line	545; kodak_timer.c	for (i = fifo_in_use(); i > 1; i--) {
	DECF	r0x04, F
	BRA	_00417_DS_
_00407_DS_:
;	.line	562; kodak_timer.c	while ((fifo_in_use() >= 2) && fifo_snoop(&a, 0) && fifo_snoop(&b, 1)) {
	CALL	_fifo_in_use
	MOVWF	r0x03
	MOVLW	0x02
	SUBWF	r0x03, W
	BTFSS	STATUS, 0
	BRA	_00409_DS_
	MOVLW	HIGH(_fifo_get_optimized_a_1_1)
	MOVWF	r0x04
	MOVLW	LOW(_fifo_get_optimized_a_1_1)
	MOVWF	r0x03
	MOVLW	0x80
	MOVWF	r0x05
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVF	r0x05, W
	MOVWF	POSTDEC1
	MOVF	r0x04, W
	MOVWF	POSTDEC1
	MOVF	r0x03, W
	MOVWF	POSTDEC1
	CALL	_fifo_snoop
	MOVWF	r0x03
	MOVLW	0x04
	ADDWF	FSR1L, F
	MOVF	r0x03, W
	BTFSC	STATUS, 2
	BRA	_00409_DS_
	MOVLW	HIGH(_fifo_get_optimized_b_1_1)
	MOVWF	r0x04
	MOVLW	LOW(_fifo_get_optimized_b_1_1)
	MOVWF	r0x03
	MOVLW	0x80
	MOVWF	r0x05
	MOVLW	0x01
	MOVWF	POSTDEC1
	MOVF	r0x05, W
	MOVWF	POSTDEC1
	MOVF	r0x04, W
	MOVWF	POSTDEC1
	MOVF	r0x03, W
	MOVWF	POSTDEC1
	CALL	_fifo_snoop
	MOVWF	r0x03
	MOVLW	0x04
	ADDWF	FSR1L, F
	MOVF	r0x03, W
	BZ	_00409_DS_
	BANKSEL	_fifo_get_optimized_a_1_1
;	.line	563; kodak_timer.c	if (((a == CMD_FADE_IN) && (b == CMD_FADE_OUT)) || ((a == CMD_FADE_OUT) && (b == CMD_FADE_IN))) {
	MOVF	_fifo_get_optimized_a_1_1, W, B
	XORLW	0x01
	BNZ	_00404_DS_
_00454_DS_:
	BANKSEL	_fifo_get_optimized_b_1_1
	MOVF	_fifo_get_optimized_b_1_1, W, B
	XORLW	0x07
	BZ	_00399_DS_
_00404_DS_:
	BANKSEL	_fifo_get_optimized_a_1_1
	MOVF	_fifo_get_optimized_a_1_1, W, B
	XORLW	0x07
	BNZ	_00409_DS_
_00458_DS_:
	BANKSEL	_fifo_get_optimized_b_1_1
	MOVF	_fifo_get_optimized_b_1_1, W, B
	XORLW	0x01
	BNZ	_00409_DS_
_00399_DS_:
;	.line	564; kodak_timer.c	fifo_get(c);
	MOVF	r0x02, W
	MOVWF	POSTDEC1
	MOVF	r0x01, W
	MOVWF	POSTDEC1
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	CALL	_fifo_get
	MOVLW	0x03
	ADDWF	FSR1L, F
;	.line	565; kodak_timer.c	fifo_get(c);
	MOVF	r0x02, W
	MOVWF	POSTDEC1
	MOVF	r0x01, W
	MOVWF	POSTDEC1
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	CALL	_fifo_get
	MOVLW	0x03
	ADDWF	FSR1L, F
	BRA	_00407_DS_
_00409_DS_:
;	.line	571; kodak_timer.c	if (fifo_get(c)) {
	MOVF	r0x02, W
	MOVWF	POSTDEC1
	MOVF	r0x01, W
	MOVWF	POSTDEC1
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	CALL	_fifo_get
	MOVWF	r0x00
	MOVLW	0x03
	ADDWF	FSR1L, F
	MOVF	r0x00, W
	BZ	_00411_DS_
;	.line	572; kodak_timer.c	return 1;
	MOVLW	0x01
	BRA	_00421_DS_
_00411_DS_:
;	.line	575; kodak_timer.c	return 0;
	CLRF	WREG
_00421_DS_:
	MOVFF	PREINC1, r0x0a
	MOVFF	PREINC1, r0x09
	MOVFF	PREINC1, r0x08
	MOVFF	PREINC1, r0x07
	MOVFF	PREINC1, r0x06
	MOVFF	PREINC1, r0x05
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__fifo_snoop	code
_fifo_snoop:
;	.line	514; kodak_timer.c	unsigned char fifo_snoop(command_t *c, unsigned char pos) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
	MOVLW	0x03
	MOVFF	PLUSW2, r0x01
	MOVLW	0x04
	MOVFF	PLUSW2, r0x02
	MOVLW	0x05
	MOVFF	PLUSW2, r0x03
;	.line	515; kodak_timer.c	if (fifo_in_use() > (pos)) {
	CALL	_fifo_in_use
	MOVWF	r0x04
	MOVF	r0x04, W
	SUBWF	r0x03, W
	BC	_00376_DS_
;	.line	516; kodak_timer.c	*c = fifo_buffer[(fifo_tail + pos) % QUEUE_SIZE];
	CLRF	r0x04
	BANKSEL	_fifo_tail
	MOVF	_fifo_tail, W, B
	ADDWF	r0x03, F
	BANKSEL	(_fifo_tail + 1)
	MOVF	(_fifo_tail + 1), W, B
	ADDWFC	r0x04, F
	CLRF	r0x04
	MOVLW	LOW(_fifo_buffer)
	ADDWF	r0x03, F
	MOVLW	HIGH(_fifo_buffer)
	ADDWFC	r0x04, F
	MOVFF	r0x03, FSR0L
	MOVFF	r0x04, FSR0H
	MOVFF	INDF0, r0x03
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x00, FSR0L
	MOVFF	r0x01, PRODL
	MOVF	r0x02, W
	CALL	__gptrput1
;	.line	517; kodak_timer.c	return 1;
	MOVLW	0x01
	BRA	_00378_DS_
_00376_DS_:
;	.line	520; kodak_timer.c	return 0;
	CLRF	WREG
_00378_DS_:
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__fifo_get	code
_fifo_get:
;	.line	504; kodak_timer.c	unsigned char fifo_get(command_t *c) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
	MOVLW	0x03
	MOVFF	PLUSW2, r0x01
	MOVLW	0x04
	MOVFF	PLUSW2, r0x02
;	.line	505; kodak_timer.c	if (fifo_in_use() != 0) {
	CALL	_fifo_in_use
	MOVWF	r0x03
	MOVF	r0x03, W
	BZ	_00368_DS_
;	.line	506; kodak_timer.c	*c = fifo_buffer[fifo_tail++ % QUEUE_SIZE];
	MOVFF	_fifo_tail, r0x03
	MOVFF	(_fifo_tail + 1), r0x04
	BANKSEL	_fifo_tail
	INCF	_fifo_tail, F, B
	BNC	_20471_DS_
	BANKSEL	(_fifo_tail + 1)
	INCF	(_fifo_tail + 1), F, B
_20471_DS_:
	CLRF	r0x04
	MOVLW	LOW(_fifo_buffer)
	ADDWF	r0x03, F
	MOVLW	HIGH(_fifo_buffer)
	ADDWFC	r0x04, F
	MOVFF	r0x03, FSR0L
	MOVFF	r0x04, FSR0H
	MOVFF	INDF0, r0x03
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x00, FSR0L
	MOVFF	r0x01, PRODL
	MOVF	r0x02, W
	CALL	__gptrput1
;	.line	507; kodak_timer.c	return 1;
	MOVLW	0x01
	BRA	_00370_DS_
_00368_DS_:
;	.line	510; kodak_timer.c	return 0;
	CLRF	WREG
_00370_DS_:
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__fifo_put	code
_fifo_put:
;	.line	494; kodak_timer.c	unsigned char fifo_put(command_t c) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
;	.line	496; kodak_timer.c	fifo_buffer[fifo_head++ % QUEUE_SIZE] = c;
	MOVFF	_fifo_head, r0x01
	MOVFF	(_fifo_head + 1), r0x02
	BANKSEL	_fifo_head
	INCF	_fifo_head, F, B
	BNC	_30472_DS_
	BANKSEL	(_fifo_head + 1)
	INCF	(_fifo_head + 1), F, B
_30472_DS_:
	CLRF	r0x02
	MOVLW	LOW(_fifo_buffer)
	ADDWF	r0x01, F
	MOVLW	HIGH(_fifo_buffer)
	ADDWFC	r0x02, F
	MOVFF	r0x01, FSR0L
	MOVFF	r0x02, FSR0H
	MOVFF	r0x00, INDF0
;	.line	497; kodak_timer.c	return 1;
	MOVLW	0x01
;	.line	500; kodak_timer.c	return 0;
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__fifo_in_use	code
_fifo_in_use:
;	.line	490; kodak_timer.c	unsigned char fifo_in_use() {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	BANKSEL	_fifo_head
;	.line	491; kodak_timer.c	return fifo_head - fifo_tail;
	MOVF	_fifo_head, W, B
	MOVWF	r0x00
	BANKSEL	_fifo_tail
	MOVF	_fifo_tail, W, B
	MOVWF	r0x01
	MOVF	r0x01, W
	SUBWF	r0x00, F
	MOVF	r0x00, W
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__led_debug	code
_led_debug:
;	.line	482; kodak_timer.c	void led_debug() {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	483; kodak_timer.c	sleep_ms(20);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x14
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	484; kodak_timer.c	LED_PIN = 1;
	BSF	_PORTBbits, 5
;	.line	485; kodak_timer.c	sleep_ms(80);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x50
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	486; kodak_timer.c	LED_PIN = 0;
	BCF	_PORTBbits, 5
;	.line	487; kodak_timer.c	sleep_ms(20);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x14
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__wait_for_command	code
_wait_for_command:
;	.line	475; kodak_timer.c	void wait_for_command() {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
_00341_DS_:
;	.line	476; kodak_timer.c	while (!fifo_in_use()) {
	CALL	_fifo_in_use
	MOVWF	r0x00
	MOVF	r0x00, W
	BZ	_00341_DS_
;	.line	479; kodak_timer.c	fifo_get_optimized(&command);
	MOVLW	HIGH(_command)
	MOVWF	r0x01
	MOVLW	LOW(_command)
	MOVWF	r0x00
	MOVLW	0x80
	MOVWF	r0x02
	MOVF	r0x02, W
	MOVWF	POSTDEC1
	MOVF	r0x01, W
	MOVWF	POSTDEC1
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	CALL	_fifo_get_optimized
	MOVLW	0x03
	ADDWF	FSR1L, F
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__my_usart_open	code
_my_usart_open:
;	.line	447; kodak_timer.c	void my_usart_open() {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	448; kodak_timer.c	SPBRG = 32; // 20MHz => 9600 baud (BRGH = 0)
	MOVLW	0x20
	MOVWF	_SPBRG
;	.line	449; kodak_timer.c	TXSTAbits.BRGH = 0; // (0 = low speed)
	BCF	_TXSTAbits, 2
;	.line	450; kodak_timer.c	TXSTAbits.SYNC = 0; // (0 = asynchronous)
	BCF	_TXSTAbits, 4
;	.line	453; kodak_timer.c	RCSTAbits.SPEN = 1; // (1 = serial port enabled)
	BSF	_RCSTAbits, 7
;	.line	456; kodak_timer.c	PIE1bits.TXIE = 0; // (1 = enabled)
	BCF	_PIE1bits, 4
;	.line	459; kodak_timer.c	PIE1bits.RCIE = 1; // (1 = enabled)
	BSF	_PIE1bits, 5
;	.line	462; kodak_timer.c	TXSTAbits.TX9 = 0; // (0 = 8-bit transmit)
	BCF	_TXSTAbits, 6
;	.line	465; kodak_timer.c	RCSTAbits.RX9 = 0; // (0 = 8-bit reception)
	BCF	_RCSTAbits, 6
;	.line	468; kodak_timer.c	RCSTAbits.CREN = 1; // (1 = Enables receiver)
	BSF	_RCSTAbits, 4
;	.line	471; kodak_timer.c	TXSTAbits.TXEN = 1; // (1 = transmit enabled)
	BSF	_TXSTAbits, 5
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__timer_control	code
_timer_control:
;	.line	362; kodak_timer.c	static void timer_control(void) __interrupt 2 {
	MOVFF	WREG, POSTDEC1
	MOVFF	STATUS, POSTDEC1
	MOVFF	BSR, POSTDEC1
	MOVFF	PRODL, POSTDEC1
	MOVFF	PRODH, POSTDEC1
	MOVFF	FSR0L, POSTDEC1
	MOVFF	FSR0H, POSTDEC1
	MOVFF	PCLATH, POSTDEC1
	MOVFF	PCLATU, POSTDEC1
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
;	.line	363; kodak_timer.c	if (PIR1bits.TMR1IF) {
	BTFSS	_PIR1bits, 0
	BRA	_00289_DS_
;	.line	364; kodak_timer.c	TMR1H = (unsigned char)(TIMER1_RELOAD >> 8);	// 8 ms delay at 8 MHz
	MOVLW	0xfd
	MOVWF	_TMR1H
;	.line	365; kodak_timer.c	TMR1L = (unsigned char)TIMER1_RELOAD;
	MOVLW	0x91
	MOVWF	_TMR1L
	BANKSEL	_timer_1_soft_postscaler
;	.line	366; kodak_timer.c	timer_1_soft_postscaler++;
	INCF	_timer_1_soft_postscaler, F, B
	BNC	_40473_DS_
	BANKSEL	(_timer_1_soft_postscaler + 1)
	INCF	(_timer_1_soft_postscaler + 1), F, B
_40473_DS_:
	BANKSEL	(_dimmer_time + 1)
;	.line	367; kodak_timer.c	if (timer_1_soft_postscaler >= dimmer_time) {
	MOVF	(_dimmer_time + 1), W, B
	BANKSEL	(_timer_1_soft_postscaler + 1)
	SUBWF	(_timer_1_soft_postscaler + 1), W, B
	BNZ	_00325_DS_
	BANKSEL	_dimmer_time
	MOVF	_dimmer_time, W, B
	BANKSEL	_timer_1_soft_postscaler
	SUBWF	_timer_1_soft_postscaler, W, B
_00325_DS_:
	BNC	_00289_DS_
	BANKSEL	_timer_1_soft_postscaler
;	.line	368; kodak_timer.c	timer_1_soft_postscaler = 0;
	CLRF	_timer_1_soft_postscaler, B
	BANKSEL	(_timer_1_soft_postscaler + 1)
	CLRF	(_timer_1_soft_postscaler + 1), B
;	.line	369; kodak_timer.c	PIR1bits.TMR1IF = 0;	/* Clear the Timer Flag  */
	BCF	_PIR1bits, 0
	BANKSEL	_dimmer_direction
;	.line	370; kodak_timer.c	if ((dimmer_direction == UP) && (dimmer_level < max_dimmer_level)) {	// if we dimm
	MOVF	_dimmer_direction, W, B
	BNZ	_00283_DS_
	BANKSEL	_max_dimmer_level
	MOVF	_max_dimmer_level, W, B
	BANKSEL	_dimmer_level
	SUBWF	_dimmer_level, W, B
	BC	_00283_DS_
	BANKSEL	_dimmer_level
;	.line	371; kodak_timer.c	dimmer_level++;
	INCF	_dimmer_level, F, B
	BRA	_00289_DS_
_00283_DS_:
	BANKSEL	_dimmer_direction
;	.line	373; kodak_timer.c	else if ((dimmer_direction == DOWN) && (dimmer_level > 0)) {
	MOVF	_dimmer_direction, W, B
	XORLW	0x01
	BNZ	_00279_DS_
_00328_DS_:
	BANKSEL	_dimmer_level
	MOVF	_dimmer_level, W, B
	BZ	_00279_DS_
	BANKSEL	_dimmer_level
;	.line	374; kodak_timer.c	dimmer_level--;
	DECF	_dimmer_level, F, B
	BRA	_00289_DS_
_00279_DS_:
;	.line	377; kodak_timer.c	T1CONbits.TMR1ON = 0;
	BCF	_T1CONbits, 0
;	.line	378; kodak_timer.c	PIE1bits.TMR1IE = 0;
	BCF	_PIE1bits, 0
_00289_DS_:
;	.line	382; kodak_timer.c	if (PIR1bits.TMR2IF) {
	BTFSS	_PIR1bits, 1
	BRA	_00294_DS_
;	.line	383; kodak_timer.c	PR2 = TIMER2_RELOAD;		// 1 ms delay at 8 MHz
	MOVLW	0x7c
	MOVWF	_PR2
;	.line	384; kodak_timer.c	PIR1bits.TMR2IF = 0;
	BCF	_PIR1bits, 1
	BANKSEL	_timer_2
;	.line	385; kodak_timer.c	timer_2++;
	INCF	_timer_2, F, B
	BNC	_50474_DS_
	BANKSEL	(_timer_2 + 1)
	INCF	(_timer_2 + 1), F, B
_50474_DS_:
	BNC	_60475_DS_
	BANKSEL	(_timer_2 + 2)
	INCF	(_timer_2 + 2), F, B
_60475_DS_:
	BNC	_70476_DS_
	BANKSEL	(_timer_2 + 3)
	INCF	(_timer_2 + 3), F, B
_70476_DS_:
;	.line	389; kodak_timer.c	if (fifo_in_use()) {
	CALL	_fifo_in_use
	MOVWF	r0x00
	MOVF	r0x00, W
	BZ	_00291_DS_
;	.line	390; kodak_timer.c	LED_PIN = 1;
	BSF	_PORTBbits, 5
	BRA	_00294_DS_
_00291_DS_:
;	.line	393; kodak_timer.c	LED_PIN = 0;
	BCF	_PORTBbits, 5
_00294_DS_:
;	.line	406; kodak_timer.c	if (PIR2bits.TMR3IF) {
	BTFSS	_PIR2bits, 1
	BRA	_00302_DS_
;	.line	407; kodak_timer.c	TMR3H = (unsigned char)(TIMER3_RELOAD >> 8);	// 8 ms delay at 8 MHz
	CLRF	_TMR3H
;	.line	408; kodak_timer.c	TMR3L = (unsigned char)TIMER3_RELOAD;
	CLRF	_TMR3L
;	.line	409; kodak_timer.c	PIR2bits.TMR3IF = 0;	/* Clear the Timer Flag  */
	BCF	_PIR2bits, 1
;	.line	412; kodak_timer.c	adc_setchannel(0);
	MOVLW	0x00
	MOVWF	POSTDEC1
	CALL	_adc_setchannel
	INCF	FSR1L, F
;	.line	413; kodak_timer.c	adc_conv();
	CALL	_adc_conv
_00295_DS_:
;	.line	414; kodak_timer.c	while(adc_busy()) {
	CALL	_adc_busy
	MOVWF	r0x00
	MOVF	r0x00, W
	BNZ	_00295_DS_
;	.line	417; kodak_timer.c	ad0 = 0xff - (adc_read() >> 2);		// potmetrene vender omvendt på boardet
	CALL	_adc_read
	MOVWF	r0x00
	MOVFF	PRODL, r0x01
	RLCF	r0x01, W
	RRCF	r0x01, F
	RRCF	r0x00, F
	RLCF	r0x01, W
	RRCF	r0x01, F
	RRCF	r0x00, F
	MOVF	r0x00, W
	SUBLW	0xff
	BANKSEL	_ad0
	MOVWF	_ad0, B
; ;multiply lit val:0x10 by variable _ad0 and store in _dimmer_time
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
	BANKSEL	_ad0
;	.line	418; kodak_timer.c	dimmer_time = (ad0 * 0x10);
	MOVF	_ad0, W, B
	MULLW	0x10
	MOVFF	PRODL, _dimmer_time
	MOVFF	PRODH, (_dimmer_time + 1)
;	.line	419; kodak_timer.c	max_dimmer_level = ad1;
	MOVFF	_ad1, _max_dimmer_level
;	.line	422; kodak_timer.c	adc_setchannel(1);
	MOVLW	0x01
	MOVWF	POSTDEC1
	CALL	_adc_setchannel
	INCF	FSR1L, F
;	.line	423; kodak_timer.c	adc_conv();
	CALL	_adc_conv
_00298_DS_:
;	.line	424; kodak_timer.c	while(adc_busy()) {
	CALL	_adc_busy
	MOVWF	r0x00
	MOVF	r0x00, W
	BNZ	_00298_DS_
;	.line	427; kodak_timer.c	ad1 = 0xff - (adc_read() >> 2);		// potmetrene vender omvendt på boardet
	CALL	_adc_read
	MOVWF	r0x00
	MOVFF	PRODL, r0x01
	RLCF	r0x01, W
	RRCF	r0x01, F
	RRCF	r0x00, F
	RLCF	r0x01, W
	RRCF	r0x01, F
	RRCF	r0x00, F
	MOVF	r0x00, W
	SUBLW	0xff
	BANKSEL	_ad1
	MOVWF	_ad1, B
_00302_DS_:
;	.line	430; kodak_timer.c	if (usart_drdy()) {
	CALL	_usart_drdy
	MOVWF	r0x00
	MOVF	r0x00, W
	BZ	_00308_DS_
;	.line	432; kodak_timer.c	command = usart_getc();
	CALL	_usart_getc
	BANKSEL	_command
	MOVWF	_command, B
	BANKSEL	_command
;	.line	433; kodak_timer.c	usart_putc(command);
	MOVF	_command, W, B
	CALL	_usart_putc
	BANKSEL	_id
;	.line	436; kodak_timer.c	id = 0;	// DEBUG
	CLRF	_id, B
;	.line	437; kodak_timer.c	command &= 0x7;
	MOVLW	0x07
	BANKSEL	_command
	ANDWF	_command, F, B
	BANKSEL	_id
;	.line	438; kodak_timer.c	if ((id == 0) || (id == eeprom_id)) {
	MOVF	_id, W, B
	BZ	_00303_DS_
	BANKSEL	_id
	MOVF	_id, W, B
	BANKSEL	_eeprom_id
	XORWF	_eeprom_id, W, B
	BNZ	_00308_DS_
_00303_DS_:
	BANKSEL	_command
;	.line	439; kodak_timer.c	fifo_put(command);
	MOVF	_command, W, B
	MOVWF	POSTDEC1
	CALL	_fifo_put
	INCF	FSR1L, F
_00308_DS_:
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	MOVFF	PREINC1, PCLATU
	MOVFF	PREINC1, PCLATH
	MOVFF	PREINC1, FSR0H
	MOVFF	PREINC1, FSR0L
	MOVFF	PREINC1, PRODH
	MOVFF	PREINC1, PRODL
	MOVFF	PREINC1, BSR
	MOVFF	PREINC1, STATUS
	MOVFF	PREINC1, WREG
	RETFIE	

; ; Starting pCode block
S_kodak_timer__phase_control	code
_phase_control:
;	.line	337; kodak_timer.c	static void phase_control(void) __interrupt 1 {
	MOVFF	WREG, POSTDEC1
	MOVFF	STATUS, POSTDEC1
	MOVFF	BSR, POSTDEC1
	MOVFF	PRODL, POSTDEC1
	MOVFF	PRODH, POSTDEC1
	MOVFF	FSR0L, POSTDEC1
	MOVFF	FSR0H, POSTDEC1
	MOVFF	PCLATH, POSTDEC1
	MOVFF	PCLATU, POSTDEC1
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	339; kodak_timer.c	if (INTCONbits.INT0IF) {
	BTFSS	_INTCONbits, 1
	BRA	_00267_DS_
;	.line	340; kodak_timer.c	INTCONbits.INT0IF = 0;		/* Clear Interrupt Flag */
	BCF	_INTCONbits, 1
	BANKSEL	_dimmer_level
;	.line	341; kodak_timer.c	dimmer_count = 0xff - dimmer_level;	/* Load Level Setting   */
	MOVF	_dimmer_level, W, B
	SUBLW	0xff
	BANKSEL	_dimmer_count
	MOVWF	_dimmer_count, B
;	.line	342; kodak_timer.c	LAMP_PIN = 0;		/* Turn Output Off */
	BCF	_PORTBbits, 3
;	.line	343; kodak_timer.c	INTCONbits.TMR0IF = 1;	/* Force Instant entry to Timer 0 Interrupt */
	BSF	_INTCONbits, 2
;	.line	344; kodak_timer.c	T0CONbits.TMR0ON = 1;	// enable timer0
	BSF	_T0CONbits, 7
;	.line	345; kodak_timer.c	INTCONbits.T0IE = 1;	/* Ensure that TMR0 Interrupt is enabled    */
	BSF	_INTCONbits, 5
_00267_DS_:
;	.line	348; kodak_timer.c	if (INTCONbits.TMR0IF) {
	BTFSS	_INTCONbits, 2
	BRA	_00273_DS_
;	.line	349; kodak_timer.c	TMR0H = (unsigned char)(TIMER0_RELOAD >> 8);
	MOVLW	0xff
	MOVWF	_TMR0H
;	.line	350; kodak_timer.c	TMR0L = (unsigned char)TIMER0_RELOAD;	/* Reload the Timer ASAP */
	MOVLW	0x5d
	MOVWF	_TMR0L
;	.line	351; kodak_timer.c	INTCONbits.TMR0IF = 0;	/* Clear the Timer Flag  */
	BCF	_INTCONbits, 2
	BANKSEL	_dimmer_count
;	.line	353; kodak_timer.c	if(dimmer_count == 0) {
	MOVF	_dimmer_count, W, B
	BNZ	_00269_DS_
;	.line	354; kodak_timer.c	LAMP_PIN = 1;	/* Turn Output ON  */
	BSF	_PORTBbits, 3
	BRA	_00273_DS_
_00269_DS_:
	BANKSEL	_dimmer_count
;	.line	357; kodak_timer.c	dimmer_count--;	/* Keep Decreasing Till Zero */
	DECF	_dimmer_count, F, B
_00273_DS_:
	MOVFF	PREINC1, FSR2L
	MOVFF	PREINC1, PCLATU
	MOVFF	PREINC1, PCLATH
	MOVFF	PREINC1, FSR0H
	MOVFF	PREINC1, FSR0L
	MOVFF	PREINC1, PRODH
	MOVFF	PREINC1, PRODL
	MOVFF	PREINC1, BSR
	MOVFF	PREINC1, STATUS
	MOVFF	PREINC1, WREG
	RETFIE	

; ; Starting pCode block
S_kodak_timer__sync_dias	code
_sync_dias:
;	.line	276; kodak_timer.c	void sync_dias(unsigned char pos) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVFF	r0x05, POSTDEC1
	MOVFF	r0x06, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
;	.line	281; kodak_timer.c	last_dimmer_level = dimmer_level;
	MOVFF	_dimmer_level, r0x01
;	.line	282; kodak_timer.c	fade_out();
	CALL	_fade_out
;	.line	284; kodak_timer.c	if (DIAS_DETECTOR_PIN) {						// we are outside slide array
	BTFSS	_PORTBbits, 4
	BRA	_00224_DS_
_00221_DS_:
;	.line	285; kodak_timer.c	while (DIAS_DETECTOR_PIN) {				// go forward to first slide
	BTFSS	_PORTBbits, 4
	BRA	_00252_DS_
;	.line	286; kodak_timer.c	FORWARD_PIN = 1;
	BSF	_PORTBbits, 2
;	.line	287; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	288; kodak_timer.c	FORWARD_PIN = 0;
	BCF	_PORTBbits, 2
;	.line	289; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
	BRA	_00221_DS_
_00224_DS_:
;	.line	293; kodak_timer.c	while (!DIAS_DETECTOR_PIN) {			// go back to first empty slide
	BTFSC	_PORTBbits, 4
	BRA	_00226_DS_
;	.line	294; kodak_timer.c	BACKWARD_PIN = 1;
	BSF	_PORTBbits, 1
;	.line	295; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	296; kodak_timer.c	BACKWARD_PIN = 0;
	BCF	_PORTBbits, 1
;	.line	297; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
	BRA	_00224_DS_
_00226_DS_:
;	.line	300; kodak_timer.c	FORWARD_PIN = 1;
	BSF	_PORTBbits, 2
;	.line	301; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	302; kodak_timer.c	FORWARD_PIN = 0;
	BCF	_PORTBbits, 2
;	.line	303; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
_00252_DS_:
;	.line	305; kodak_timer.c	for (i = 0; i < (pos - 1); i++) {		// and go to slide at pos again
	CLRF	r0x02
_00237_DS_:
	MOVFF	r0x00, r0x03
	CLRF	r0x04
	MOVLW	0xff
	ADDWF	r0x03, F
	BTFSS	STATUS, 0
	DECF	r0x04, F
	MOVFF	r0x02, r0x05
	CLRF	r0x06
	MOVF	r0x06, W
	ADDLW	0x80
	MOVWF	PRODL
	MOVF	r0x04, W
	ADDLW	0x80
	SUBWF	PRODL, W
	BNZ	_00260_DS_
	MOVF	r0x03, W
	SUBWF	r0x05, W
_00260_DS_:
	BC	_00240_DS_
;	.line	306; kodak_timer.c	FORWARD_PIN = 1;
	BSF	_PORTBbits, 2
;	.line	307; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	308; kodak_timer.c	FORWARD_PIN = 0;
	BCF	_PORTBbits, 2
;	.line	309; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	305; kodak_timer.c	for (i = 0; i < (pos - 1); i++) {		// and go to slide at pos again
	INCF	r0x02, F
	BRA	_00237_DS_
_00240_DS_:
;	.line	311; kodak_timer.c	dias_position = pos;
	MOVFF	r0x00, _dias_position
	BANKSEL	_direction
;	.line	312; kodak_timer.c	direction = FORWARD;
	CLRF	_direction, B
	BANKSEL	_dias_num
;	.line	314; kodak_timer.c	if (!dias_num) {										// if first time count the slides
	MOVF	_dias_num, W, B
	BTFSS	STATUS, 2
	BRA	_00234_DS_
_00230_DS_:
;	.line	315; kodak_timer.c	while (!DIAS_DETECTOR_PIN) {			// go forward to last slide
	BTFSC	_PORTBbits, 4
	BRA	_00256_DS_
;	.line	316; kodak_timer.c	FORWARD_PIN = 1;
	BSF	_PORTBbits, 2
;	.line	317; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	318; kodak_timer.c	FORWARD_PIN = 0;
	BCF	_PORTBbits, 2
;	.line	319; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
	BANKSEL	_dias_num
;	.line	320; kodak_timer.c	dias_num++;
	INCF	_dias_num, F, B
	BRA	_00230_DS_
_00256_DS_:
;	.line	322; kodak_timer.c	for (i = 0; i < dias_num ; i++) {	// and go back to first slide
	CLRF	r0x00
_00241_DS_:
	BANKSEL	_dias_num
	MOVF	_dias_num, W, B
	SUBWF	r0x00, W
	BC	_00234_DS_
;	.line	323; kodak_timer.c	BACKWARD_PIN = 1;
	BSF	_PORTBbits, 1
;	.line	324; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	325; kodak_timer.c	BACKWARD_PIN = 0;
	BCF	_PORTBbits, 1
;	.line	326; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	322; kodak_timer.c	for (i = 0; i < dias_num ; i++) {	// and go back to first slide
	INCF	r0x00, F
	BRA	_00241_DS_
_00234_DS_:
;	.line	331; kodak_timer.c	dimmer_level = last_dimmer_level;
	MOVFF	r0x01, _dimmer_level
	BANKSEL	_dimmer_level
;	.line	332; kodak_timer.c	if (dimmer_level) {
	MOVF	_dimmer_level, W, B
	BZ	_00245_DS_
;	.line	333; kodak_timer.c	fade_in();
	CALL	_fade_in
_00245_DS_:
	MOVFF	PREINC1, r0x06
	MOVFF	PREINC1, r0x05
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__backward_dias	code
_backward_dias:
;	.line	247; kodak_timer.c	void backward_dias(void) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
;	.line	249; kodak_timer.c	if (DIAS_DETECTOR_PIN) {						// if we are out of sync, sync again to last position
	BTFSS	_PORTBbits, 4
	BRA	_00196_DS_
	BANKSEL	_dias_position
;	.line	250; kodak_timer.c	sync_dias(dias_position);
	MOVF	_dias_position, W, B
	MOVWF	POSTDEC1
	CALL	_sync_dias
	INCF	FSR1L, F
_00196_DS_:
	BANKSEL	_dias_position
;	.line	254; kodak_timer.c	if (dias_position == 1) {
	MOVF	_dias_position, W, B
	XORLW	0x01
	BNZ	_00198_DS_
;	.line	255; kodak_timer.c	for (i = 0; i < (dias_num - 1); i++) {	// and go back to first slide again
	CLRF	r0x00
_00202_DS_:
	MOVFF	_dias_num, r0x01
	CLRF	r0x02
	MOVLW	0xff
	ADDWF	r0x01, F
	BTFSS	STATUS, 0
	DECF	r0x02, F
	MOVFF	r0x00, r0x03
	CLRF	r0x04
	MOVF	r0x04, W
	ADDLW	0x80
	MOVWF	PRODL
	MOVF	r0x02, W
	ADDLW	0x80
	SUBWF	PRODL, W
	BNZ	_00216_DS_
	MOVF	r0x01, W
	SUBWF	r0x03, W
_00216_DS_:
	BC	_00205_DS_
;	.line	256; kodak_timer.c	FORWARD_PIN = 1;
	BSF	_PORTBbits, 2
;	.line	257; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	258; kodak_timer.c	FORWARD_PIN = 0;
	BCF	_PORTBbits, 2
;	.line	259; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	255; kodak_timer.c	for (i = 0; i < (dias_num - 1); i++) {	// and go back to first slide again
	INCF	r0x00, F
	BRA	_00202_DS_
_00205_DS_:
;	.line	261; kodak_timer.c	dias_position = dias_num;
	MOVFF	_dias_num, _dias_position
	BRA	_00199_DS_
_00198_DS_:
;	.line	264; kodak_timer.c	BACKWARD_PIN = 1;
	BSF	_PORTBbits, 1
;	.line	265; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	266; kodak_timer.c	BACKWARD_PIN = 0;
	BCF	_PORTBbits, 1
;	.line	267; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
	BANKSEL	_dias_position
;	.line	268; kodak_timer.c	dias_position--;
	DECF	_dias_position, F, B
_00199_DS_:
;	.line	271; kodak_timer.c	if (DIAS_DETECTOR_PIN) {						// if we are out of sync, sync again to last position
	BTFSS	_PORTBbits, 4
	BRA	_00206_DS_
	BANKSEL	_dias_position
;	.line	272; kodak_timer.c	sync_dias(dias_position);
	MOVF	_dias_position, W, B
	MOVWF	POSTDEC1
	CALL	_sync_dias
	INCF	FSR1L, F
_00206_DS_:
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__forward_dias	code
_forward_dias:
;	.line	218; kodak_timer.c	void forward_dias(void) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
;	.line	220; kodak_timer.c	if (DIAS_DETECTOR_PIN) {						// if we are out of sync, sync again to last position
	BTFSS	_PORTBbits, 4
	BRA	_00170_DS_
	BANKSEL	_dias_position
;	.line	221; kodak_timer.c	sync_dias(dias_position);
	MOVF	_dias_position, W, B
	MOVWF	POSTDEC1
	CALL	_sync_dias
	INCF	FSR1L, F
_00170_DS_:
	BANKSEL	_dias_position
;	.line	225; kodak_timer.c	if (dias_position == dias_num) {
	MOVF	_dias_position, W, B
	BANKSEL	_dias_num
	XORWF	_dias_num, W, B
	BNZ	_00172_DS_
;	.line	226; kodak_timer.c	for (i = 0; i < (dias_num - 1); i++) {	// and go back to first slide again
	CLRF	r0x00
_00176_DS_:
	MOVFF	_dias_num, r0x01
	CLRF	r0x02
	MOVLW	0xff
	ADDWF	r0x01, F
	BTFSS	STATUS, 0
	DECF	r0x02, F
	MOVFF	r0x00, r0x03
	CLRF	r0x04
	MOVF	r0x04, W
	ADDLW	0x80
	MOVWF	PRODL
	MOVF	r0x02, W
	ADDLW	0x80
	SUBWF	PRODL, W
	BNZ	_00190_DS_
	MOVF	r0x01, W
	SUBWF	r0x03, W
_00190_DS_:
	BC	_00179_DS_
;	.line	227; kodak_timer.c	BACKWARD_PIN = 1;
	BSF	_PORTBbits, 1
;	.line	228; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	229; kodak_timer.c	BACKWARD_PIN = 0;
	BCF	_PORTBbits, 1
;	.line	230; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	226; kodak_timer.c	for (i = 0; i < (dias_num - 1); i++) {	// and go back to first slide again
	INCF	r0x00, F
	BRA	_00176_DS_
_00179_DS_:
;	.line	232; kodak_timer.c	dias_position = 1;
	MOVLW	0x01
	BANKSEL	_dias_position
	MOVWF	_dias_position, B
	BRA	_00173_DS_
_00172_DS_:
;	.line	235; kodak_timer.c	FORWARD_PIN = 1;
	BSF	_PORTBbits, 2
;	.line	236; kodak_timer.c	sleep_ms(NEXT_DIAS_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0x20
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
;	.line	237; kodak_timer.c	FORWARD_PIN = 0;
	BCF	_PORTBbits, 2
;	.line	238; kodak_timer.c	sleep_ms(DIAS_CHANGE_TIME);
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x00
	MOVWF	POSTDEC1
	MOVLW	0x03
	MOVWF	POSTDEC1
	MOVLW	0xe8
	MOVWF	POSTDEC1
	CALL	_sleep_ms
	MOVLW	0x04
	ADDWF	FSR1L, F
	BANKSEL	_dias_position
;	.line	239; kodak_timer.c	dias_position++;
	INCF	_dias_position, F, B
_00173_DS_:
;	.line	242; kodak_timer.c	if (DIAS_DETECTOR_PIN) {						// if we are out of sync, sync again to last position
	BTFSS	_PORTBbits, 4
	BRA	_00180_DS_
	BANKSEL	_dias_position
;	.line	243; kodak_timer.c	sync_dias(dias_position);
	MOVF	_dias_position, W, B
	MOVWF	POSTDEC1
	CALL	_sync_dias
	INCF	FSR1L, F
_00180_DS_:
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__fade_out	code
_fade_out:
;	.line	202; kodak_timer.c	void fade_out(void) {		// in 4 seconds
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	208; kodak_timer.c	dimmer_direction = DOWN;
	MOVLW	0x01
	BANKSEL	_dimmer_direction
	MOVWF	_dimmer_direction, B
;	.line	209; kodak_timer.c	PIR1bits.TMR1IF = 1;	/* Force Instant entry to Timer 1 Interrupt */
	BSF	_PIR1bits, 0
;	.line	210; kodak_timer.c	T1CONbits.TMR1ON = 1;	// enable timer1
	BSF	_T1CONbits, 0
;	.line	211; kodak_timer.c	PIE1bits.TMR1IE = 1;	/* Ensure that TMR1 Interrupt is enabled    */
	BSF	_PIE1bits, 0
_00161_DS_:
	BANKSEL	_dimmer_level
;	.line	212; kodak_timer.c	while (dimmer_level > 0) {
	MOVF	_dimmer_level, W, B
	BNZ	_00161_DS_
;	.line	215; kodak_timer.c	INTCONbits.INT0IE = 0;	// disable zero-cross
	BCF	_INTCONbits, 4
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__fade_in	code
_fade_in:
;	.line	186; kodak_timer.c	void fade_in(void) {		// in 4 seconds
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	192; kodak_timer.c	INTCONbits.INT0IE = 1;	// enable zero-cross
	BSF	_INTCONbits, 4
	BANKSEL	_dimmer_direction
;	.line	193; kodak_timer.c	dimmer_direction = UP;
	CLRF	_dimmer_direction, B
;	.line	194; kodak_timer.c	PIR1bits.TMR1IF = 1;	/* Force Instant entry to Timer 1 Interrupt */
	BSF	_PIR1bits, 0
;	.line	195; kodak_timer.c	T1CONbits.TMR1ON = 1;	// enable timer1
	BSF	_T1CONbits, 0
;	.line	196; kodak_timer.c	PIE1bits.TMR1IE = 1;	/* Ensure that TMR1 Interrupt is enabled    */
	BSF	_PIE1bits, 0
_00150_DS_:
	BANKSEL	_max_dimmer_level
;	.line	197; kodak_timer.c	while (dimmer_level < max_dimmer_level) {
	MOVF	_max_dimmer_level, W, B
	BANKSEL	_dimmer_level
	SUBWF	_dimmer_level, W, B
	BNC	_00150_DS_
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_kodak_timer__sleep_ms	code
_sleep_ms:
;	.line	176; kodak_timer.c	void sleep_ms(unsigned long ms) {
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVFF	r0x05, POSTDEC1
	MOVFF	r0x06, POSTDEC1
	MOVFF	r0x07, POSTDEC1
	MOVFF	r0x08, POSTDEC1
	MOVFF	r0x09, POSTDEC1
	MOVFF	r0x0a, POSTDEC1
	MOVFF	r0x0b, POSTDEC1
	MOVFF	r0x0c, POSTDEC1
	MOVFF	r0x0d, POSTDEC1
	MOVFF	r0x0e, POSTDEC1
	MOVFF	r0x0f, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
	MOVLW	0x03
	MOVFF	PLUSW2, r0x01
	MOVLW	0x04
	MOVFF	PLUSW2, r0x02
	MOVLW	0x05
	MOVFF	PLUSW2, r0x03
;	.line	178; kodak_timer.c	start_timer_2 = timer_2;	
	MOVFF	_timer_2, r0x04
	MOVFF	(_timer_2 + 1), r0x05
	MOVFF	(_timer_2 + 2), r0x06
	MOVFF	(_timer_2 + 3), r0x07
_00136_DS_:
;	.line	181; kodak_timer.c	while ( (((signed long)(timer_2 - start_timer_2) < 0) ? (-1 * (timer_2 - start_timer_2)) : (timer_2 - start_timer_2)) < ms) {
	MOVF	r0x04, W
	BANKSEL	_timer_2
	SUBWF	_timer_2, W, B
	MOVWF	r0x08
	MOVF	r0x05, W
	BANKSEL	(_timer_2 + 1)
	SUBWFB	(_timer_2 + 1), W, B
	MOVWF	r0x09
	MOVF	r0x06, W
	BANKSEL	(_timer_2 + 2)
	SUBWFB	(_timer_2 + 2), W, B
	MOVWF	r0x0a
	MOVF	r0x07, W
	BANKSEL	(_timer_2 + 3)
	SUBWFB	(_timer_2 + 3), W, B
	MOVWF	r0x0b
	MOVFF	r0x08, r0x0c
	MOVFF	r0x09, r0x0d
	MOVFF	r0x0a, r0x0e
	MOVFF	r0x0b, r0x0f
	BSF	STATUS, 0
	BTFSS	r0x0f, 7
	BCF	STATUS, 0
	BNC	_00141_DS_
	MOVF	r0x0b, W
	MOVWF	POSTDEC1
	MOVF	r0x0a, W
	MOVWF	POSTDEC1
	MOVF	r0x09, W
	MOVWF	POSTDEC1
	MOVF	r0x08, W
	MOVWF	POSTDEC1
	MOVLW	0xff
	MOVWF	POSTDEC1
	MOVLW	0xff
	MOVWF	POSTDEC1
	MOVLW	0xff
	MOVWF	POSTDEC1
	MOVLW	0xff
	MOVWF	POSTDEC1
	CALL	__mullong
	MOVWF	r0x0c
	MOVFF	PRODL, r0x0d
	MOVFF	PRODH, r0x0e
	MOVFF	FSR0L, r0x0f
	MOVLW	0x08
	ADDWF	FSR1L, F
	BRA	_00142_DS_
_00141_DS_:
	MOVFF	r0x08, r0x0c
	MOVFF	r0x09, r0x0d
	MOVFF	r0x0a, r0x0e
	MOVFF	r0x0b, r0x0f
_00142_DS_:
	MOVF	r0x03, W
	SUBWF	r0x0f, W
	BNZ	_00145_DS_
	MOVF	r0x02, W
	SUBWF	r0x0e, W
	BNZ	_00145_DS_
	MOVF	r0x01, W
	SUBWF	r0x0d, W
	BNZ	_00145_DS_
	MOVF	r0x00, W
	SUBWF	r0x0c, W
_00145_DS_:
	BTFSS	STATUS, 0
	BRA	_00136_DS_
	MOVFF	PREINC1, r0x0f
	MOVFF	PREINC1, r0x0e
	MOVFF	PREINC1, r0x0d
	MOVFF	PREINC1, r0x0c
	MOVFF	PREINC1, r0x0b
	MOVFF	PREINC1, r0x0a
	MOVFF	PREINC1, r0x09
	MOVFF	PREINC1, r0x08
	MOVFF	PREINC1, r0x07
	MOVFF	PREINC1, r0x06
	MOVFF	PREINC1, r0x05
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	



; Statistics:
; code size:	 3712 (0x0e80) bytes ( 2.83%)
;           	 1856 (0x0740) words
; udata size:	  282 (0x011a) bytes (15.74%)
; access size:	   16 (0x0010) bytes


	end
